#include "PreCompile.h"
#include "App.h"

// Construct the App
App::App() :
	m_pFramework(NULL),
	m_bIsShowUI(false),
	m_bDisposed(false)
{
	Initialize();
}

// Detructe the App
App::~App()
{
	Destory();
}

// Initialize the App
void App::Initialize()
{
	// Create the framework
	CreateFramework();
}

// Destory the App
void App::Destory()
{
	if (!GetDisposed())
	{
		SetDisposed(true);

		// Destory the framework
		DestoryFramework();
	}
}

// Create the framework
void App::CreateFramework()
{
	m_Loader.Load(FRAMEWORK_NAME);

	IFramework* pFramework = m_Loader.Data();

	SetFramework(pFramework);
}

// Destory the framework
void App::DestoryFramework()
{

}

// Start the framework
bool App::StartFramework()
{
	if (GetFramework() == NULL)
	{
		return false;
	}

	if (!GetFramework()->Start())
	{
		return false;
	}

	return true;
}

// Stop the the framework
bool App::StopFramework()
{
	if (GetFramework() == NULL)
	{
		return false;
	}

	if (!GetFramework()->Stop())
	{
		return false;
	}

	return true;
}

// Start the Framework
bool App::Start()
{
	// Start the the framework
	if (!StartFramework())
	{
		return false;
	}

	return true;
}

// Stop the Framework
bool App::Stop()
{
	// Stop the the framework
	StopFramework();

	return true;
}

// Is core's debug mode
bool App::IsDebugMode()
{
	if (GetFramework() == NULL)
	{
		return true;
	}

	return GetFramework()->IsDebugMode();
}
